% Set up parameters

%% Preference
pr.gam = 1;                         % risk aversion

if (index_case==1)                  % Frisch elasticity
    pr.sig = 2.5;
else
    pr.sig = 2.0;
end

%% Government 

if (index_case<=2)                  % fraction of Government Expenditure
    pr.g = 0.233;
else
    pr.g = 0.188;
end
pr.tau   = 0.181;                   % tau parameter in HSV tax function
pr.theta = 0;                       % taste for redistribution

%% Wage Distribution: Setup
pr.na     = 10000;                  % number of grid points for alpha shocks
pr.wmin   = 0.05;                   % minimum wage  
pr.wmax   = 74;                     % maximum wage
pr.vy     = 0.4117;                 % normal variance of log earnings

if (index_case <=2)                 % variance of log consumption
    pr.vc     = 0.18; 
else
    pr.vc = 0.332*(1-0.296); 
end       
pr.va     = pr.vc/(1-pr.tau)^2;                                   % variance of uninsurable shocks
pr.ve     = 0;                                                    % variance of insurable shocks

if (index_case <=2)                                               % Pareto tail parameter 
   pr.pareto = inf;
elseif (index_case==3)
    pr.pareto = 2.2; 
elseif (index_case == 4)
    pr.pareto = 2.34;
else
    pr.pareto = 3.38*(1-pr.tau);
end

if (index_case <=2)
    temp.ans  = fsolve(@(x) alphadist_LN(x,pr),[-pr.va/2 pr.va^(1/2)],optimset('TolX',1e-12,'Display','off'));  % alpha distribution, Log-normal 
    alphadist_LN(temp.ans,pr); clc
else 
    temp.ans  = fsolve(@(x) alphadist(x,pr),[log((pr.pareto-1)/pr.pareto)-(pr.va-1/pr.pareto^2)/2 (pr.va-1/pr.pareto^2)^(1/2)],optimset('TolX',1e-12,'Display','off'));  % alpha distribution
    alphadist(temp.ans,pr); clc
end 

load w                              % exp(alpha)
load pai                            % probablity measure
load pdf                            % density

%% Model Inputs
pw    = w.^-pr.theta./sum(pai.*w.^-pr.theta);                 % Pareto Weights: exp(alpha)^-theta
pr.Om = exp(-(1+pr.sig)/pr.sig*pr.ve/2);                      % Omega in utility

clear temp; delete w.mat pai.mat pdf.mat;